package com.ymatou.iapi.settlement.service;

import org.json.JSONObject;

import com.ymatou.iapi.settlement.parameter.resp.GetAdSettlementInfoResp;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;

/**
 *生成广告费率信息接口Call FreeMaker Template自动生成代码
 */
public class QueryAdSettlementInfoCall extends YmatouBaseCall {
	private static String opurl = "/api/queryAdSettlementInfo";

	public QueryAdSettlementInfoCall() {
		super(EnvSetup.getSystemUrl("settlement_iapi"), opurl, "POST", "JSON");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept",
				"text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public JSONObject getData() {
		JSONObject Data = null;
		try {
			Data = new JSONObject(getReturnData()).getJSONObject("data");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Data;
	}

	public GetAdSettlementInfoResp getResults() {

		GetAdSettlementInfoResp resp = new GetAdSettlementInfoResp();

		try {
			resp = (GetAdSettlementInfoResp) FormatUtil.GSONToObject(getData()
					.toString(), GetAdSettlementInfoResp.class);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return resp;

	}

}
